<template>
  <a-layout class="web-default-layout">
    <a-layout-header>
      <DefaultHeader />
    </a-layout-header>
    <a-layout class="drawer-cls">
      <a-layout-sider :width="200" v-model:collapsed="collapsed" class="menu-left">
        <div class="menu-box">
          <a-row class="menu-title">
            <span v-if="!collapsed">{{ title }}</span>
            <SvgIcon v-else class="title-icon" name="menu-title" />
          </a-row>
          <div class="menu-content">
            <Sider />
            <a-row class="menu-button">
              <a-button @click="() => (collapsed = !collapsed)" class="button-simple non-border">
                <MenuUnfoldOutlined v-if="collapsed" />
                <MenuFoldOutlined v-else />
              </a-button>
            </a-row>
          </div>
        </div>
      </a-layout-sider>
      <a-layout-content class="layout-content" id="layout-content">
        <RouterView />
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<script lang="ts" setup name="DefaultLayout">
import { ref } from 'vue'
import Sider from './sider/index.vue'
import DefaultHeader from './header/index.vue'
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons-vue'

const collapsed = ref(false)
const title = window.systemName
</script>
<style lang="less" scoped>
// 不展示滚动条，但是有滚动效果
.no-scrollbar {
  // 对于 Firefox 6 及以上版本
  scrollbar-width: none;
  // 针对 Chrome, Edge 和 Safari
  &::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
}
.web-default-layout {
  display: flex;
  width: 100%;
  height: 100%;
  .ant-layout-header {
    display: flex;
    height: 56px;
    line-height: 56px;
    padding: 0;
    background: var(--color-header-background);
    font-size: 14px;
    font-family: '思源黑体';
    color: var(--color-text-white);
  }
  .menu-left {
    background: var(--color-text-white);
    .menu-box {
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100%;
    }
    .menu-title {
      flex: 0 0 auto;
      border-bottom: 1px solid var(--color-info-background);
      height: 50px;
      font-size: 16px;
      font-weight: 600;
      line-height: 16px;
      align-items: center;
      justify-content: center;
      .title-icon {
        width: 32px;
        height: 32px;
      }
      span {
        width: 100%;
        padding-left: 15px;
      }
      span,
      .title-icon {
        transition-duration: 0.5s;
      }
    }
    .menu-content {
      .no-scrollbar;
      flex: 0 0 auto;
      height: calc(100% - 50px);
      display: flex;
      flex-direction: column;
      overflow-y: auto;
    }
    .menu-button {
      margin-top: 10px;
      height: 40px;
      .anticon > * {
        width: 16px;
        height: 16px;
      }
    }
  }
  .ant-layout-content {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
}
.drawer-cls {
  overflow: hidden;
  position: relative;
}
</style>
